<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>couchdbkit.utils</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="couchdbkit-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="couchdbkit-module.html">Package&nbsp;couchdbkit</a> ::
        Module&nbsp;utils
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="couchdbkit.utils-module.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module utils</h1><p class="nomargin-top"><span class="codelink"><a href="couchdbkit.utils-pysrc.html">source&nbsp;code</a></span></p>
<p>Mostly utility functions couchdbkit uses internally that don't really 
  belong anywhere else in the modules.</p>

<!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Functions</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Functions"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="splitunc"></a><span class="summary-sig-name">splitunc</span>(<span class="summary-sig-arg">p</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="couchdbkit.utils-pysrc.html#splitunc">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="split_path"></a><span class="summary-sig-name">split_path</span>(<span class="summary-sig-arg">path</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="couchdbkit.utils-pysrc.html#split_path">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="validate_dbname"></a><span class="summary-sig-name">validate_dbname</span>(<span class="summary-sig-arg">name</span>)</span><br />
      validate dbname</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="couchdbkit.utils-pysrc.html#validate_dbname">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="to_bytestring"></a><span class="summary-sig-name">to_bytestring</span>(<span class="summary-sig-arg">s</span>)</span><br />
      convert to bytestring an unicode</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="couchdbkit.utils-pysrc.html#to_bytestring">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="read_file"></a><span class="summary-sig-name">read_file</span>(<span class="summary-sig-arg">fname</span>,
        <span class="summary-sig-arg">utf8</span>=<span class="summary-sig-default">True</span>,
        <span class="summary-sig-arg">force_read</span>=<span class="summary-sig-default">False</span>)</span><br />
      read file content</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="couchdbkit.utils-pysrc.html#read_file">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdbkit.utils-module.html#sign_file" class="summary-sig-name">sign_file</a>(<span class="summary-sig-arg">file_path</span>)</span><br />
      return md5 hash from file content</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="couchdbkit.utils-pysrc.html#sign_file">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdbkit.utils-module.html#write_content" class="summary-sig-name">write_content</a>(<span class="summary-sig-arg">fname</span>,
        <span class="summary-sig-arg">content</span>)</span><br />
      write content in a file</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="couchdbkit.utils-pysrc.html#write_content">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdbkit.utils-module.html#write_json" class="summary-sig-name">write_json</a>(<span class="summary-sig-arg">filename</span>,
        <span class="summary-sig-arg">content</span>)</span><br />
      serialize content in json and save it</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="couchdbkit.utils-pysrc.html#write_json">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdbkit.utils-module.html#read_json" class="summary-sig-name">read_json</a>(<span class="summary-sig-arg">filename</span>,
        <span class="summary-sig-arg">use_environment</span>=<span class="summary-sig-default">False</span>)</span><br />
      read a json file and deserialize</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="couchdbkit.utils-pysrc.html#read_json">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Variables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="VALID_DB_NAME"></a><span class="summary-name">VALID_DB_NAME</span> = <code title="re.compile(r'^[a-z][a-z0-9_\$\(\)\+-/]*$')">re.compile(r'^<code class="re-group">[</code>a<code class="re-op">-</code>z<code class="re-group">]</code><code class="re-group">[</code>a<code class="re-op">-</code>z0<code class="re-op">-</code>9_\$\(\)\+<code class="re-op">-</code>/<code class="re-group">]</code><code class="re-op">*</code>$')</code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="SPECIAL_DBS"></a><span class="summary-name">SPECIAL_DBS</span> = <code title="('_users', '_replicator')"><code class="variable-group">(</code><code class="variable-quote">'</code><code class="variable-string">_users</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">_replicator</code><code class="variable-quote">'</code><code class="variable-group">)</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="__package__"></a><span class="summary-name">__package__</span> = <code title="'couchdbkit'"><code class="variable-quote">'</code><code class="variable-string">couchdbkit</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Function Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-FunctionDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="sign_file"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">sign_file</span>(<span class="sig-arg">file_path</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="couchdbkit.utils-pysrc.html#sign_file">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>return md5 hash from file content</p>
  <p>:attr file_path: string, path of file</p>
  <p>:return: string, md5 hexdigest</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="write_content"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">write_content</span>(<span class="sig-arg">fname</span>,
        <span class="sig-arg">content</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="couchdbkit.utils-pysrc.html#write_content">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>write content in a file</p>
  <p>:attr fname: string,filename :attr content: string</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="write_json"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">write_json</span>(<span class="sig-arg">filename</span>,
        <span class="sig-arg">content</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="couchdbkit.utils-pysrc.html#write_json">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>serialize content in json and save it</p>
  <p>:attr filename: string :attr content: string</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="read_json"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">read_json</span>(<span class="sig-arg">filename</span>,
        <span class="sig-arg">use_environment</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="couchdbkit.utils-pysrc.html#read_json">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>read a json file and deserialize</p>
  <p>:attr filename: string :attr use_environment: boolean, default is 
  False. If True, replace environment variable by their value in file 
  content</p>
  <p>:return: dict or list</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="couchdbkit-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Fri May  4 11:48:40 2012
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
